package com.yonyougov.devops.cruxcisupport.util;

import java.io.File;

public class FileUtils {

    /**
     * 重命名文件
     *
     * @param newFileName
     * @return
     */
    public static File renameFile(File oldFile, String newFileName) throws Exception {
        String newFilePath = oldFile.getParentFile().getAbsolutePath() + File.separator + newFileName;
        System.out.println(newFilePath);
        File newFile = new File(newFilePath);
        if (oldFile.exists() && oldFile.isFile()) {
            oldFile.renameTo(newFile);
            return newFile;
        }
        throw new Exception("文件重新命名异常");
    }
}
